﻿using System;
using System.IO;
using System.Collections.Generic;
using System.Text;

namespace SBPweb.MediaCenter.Common.Files
{

    public class FileUriHelper
    {

        public static string GetExtension(Uri uri)
        {
            string fileName = uri.Segments[uri.Segments.Length - 1];
            int pos = fileName.LastIndexOf(".");
            return fileName.Substring(pos + 1);
        }

        public static string GetExtensionsFilter(IList<string> list)
        {
            return GetExtensionsFilter(list, ";");
        }

        public static string GetExtensionsFilter(IList<string> list, string separator)
        {
            StringBuilder sb = new StringBuilder();
            foreach (string str in list)
            {
                if (sb.Length > 0)
                {
                    sb.Append(separator);
                }
                sb.Append("*." + str);
            }
            return sb.ToString();
        }

    }

}